import Vue from 'vue'
// vue filter
Vue.filter('date-format', function (date) {
  if (!date) {
    return '----'
  } else {
    var d = new Date(date)
    var year = d.getFullYear()
    var month = ('0' + (d.getMonth() + 1)).slice(-2)
    var day = ('0' + d.getDate()).slice(-2)
    var hour = ('0' + d.getHours()).slice(-2)
    var minutes = ('0' + d.getMinutes()).slice(-2)
    var seconds = ('0' + d.getSeconds()).slice(-2)
    return (
      year +
      '-' +
      month +
      '-' +
      day +
      ' ' +
      hour +
      ':' +
      minutes +
      ':' +
      seconds
    )
  }
})

Vue.filter('date', function (date) {
  if (!date) {
    return '----'
  } else {
    var d = new Date(date)
    var year = d.getFullYear()
    var month = ('0' + (d.getMonth() + 1)).slice(-2)
    var day = ('0' + d.getDate()).slice(-2)
    return year + '-' + month + '-' + day
  }
})
